package com.itHuangTao.tank.ui;

import com.almasb.fxgl.app.scene.FXGLMenu;
import com.almasb.fxgl.app.scene.MenuType;
import com.almasb.fxgl.dsl.FXGL;
import com.almasb.fxgl.texture.Texture;
import com.itHuangTao.tank.introduce.*;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;

public class HelpMenu extends FXGLMenu {
    public HelpMenu() {
        super(MenuType.GAME_MENU);

        Texture texture = FXGL.texture("menuSceneBg.png");

        StackPane pane = new StackPane(texture);
        //设置窗口大小
        pane.setPrefSize(FXGL.getAppWidth(), FXGL.getAppHeight());
        //设置背景色(黑色)
        pane.setStyle("-fx-background-color: black");

        //设置六个按钮
        //1.
        Button btnCreate = new Button("创作简述");
        btnCreate.getStyleClass().add("menu-btn");//利用css设置样式
        btnCreate.setOnAction(event -> FXGL.getSceneService().pushSubScene(new Creater()));

        //2.
        Button btnProp = new Button("道具说明");
        btnProp.getStyleClass().add("menu-btn");//利用css设置样式
        btnProp.setOnAction(event -> {
            FXGL.getSceneService().pushSubScene(new Prop());
        });

        //3.
        Button btnLevel = new Button("关卡说明");
        btnLevel.getStyleClass().add("menu-btn");//利用css设置样式
        btnLevel.setOnAction(event -> {
            FXGL.getSceneService().pushSubScene(new Level());
        });

        //4.
        Button btnEnvironment = new Button("墙体环境说明");
        btnEnvironment.getStyleClass().add("menu-btn");//利用css设置样式
        btnEnvironment.setOnAction(event -> {
            FXGL.getSceneService().pushSubScene(new Environment());
        });

        //5.
        Button btnChoose = new Button("基本操作说明及初始关卡选择");
        btnChoose.getStyleClass().add("menu-btn");//利用css设置样式
        btnChoose.setOnAction(event -> {
            FXGL.getSceneService().pushSubScene(new Choose());
        });

        //6.
        Button btnReturnMainMenu = new Button("返回主菜单");
        btnReturnMainMenu.getStyleClass().add("menu-btn");//利用css设置样式
        btnReturnMainMenu.setOnAction(event -> {
            FXGL.getGameController().gotoMainMenu();
        });


        //设置垂直间隔为30个像素点(并存放上述按钮对象)
        VBox box1 = new VBox(30, btnCreate, btnProp, btnLevel);
        VBox box2 = new VBox(30, btnEnvironment, btnChoose, btnReturnMainMenu);
        box1.setLayoutX(200);
        box1.setLayoutY(350);
        box2.setLayoutX(400);
        box2.setLayoutY(350);

        //加入所有变量
        getContentRoot().getChildren().addAll(pane, box1, box2);
    }
}
